﻿<phone:PhoneApplicationPage 
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:NYTimes="clr-namespace:NYTimes;assembly=NYTimesSilverlightKit"
	xmlns:NYTimes_ValueConverters="clr-namespace:NYTimes.ValueConverters;assembly=NYTimesSilverlightKit"
	xmlns:Microsoft_Advertising_Mobile_UI="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI"
	mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
	x:Class="MostPopular.DetailPage"
	Orientation="Portrait"
	shell:SystemTray.IsVisible="True"
    xmlns:anim="clr-namespace:PhoneHelpers"
	d:DataContext="{d:DesignInstance NYTimes:MostPopular, IsDesignTimeCreatable=True}">

	<phone:PhoneApplicationPage.Resources>
		<NYTimes_ValueConverters:VisibleIfNotEmptyConverter x:Key="VisibleIfNotEmptyConverter"/>
		<NYTimes_ValueConverters:DateTimeConverter x:Key="DateTimeConverter"/>
		<DataTemplate x:Key="StringTemplate">
			<StackPanel>
				<TextBlock Text="{Binding Mode=OneWay}"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate x:Key="StringTemplate1">
			<StackPanel>
				<TextBlock Text="{Binding Mode=OneWay}"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate x:Key="StringTemplate2">
			<StackPanel>
				<TextBlock Text="{Binding Mode=OneWay}"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate x:Key="StringTemplate3">
			<StackPanel>
				<TextBlock Text="{Binding Mode=OneWay}"/>
			</StackPanel>
		</DataTemplate>
	</phone:PhoneApplicationPage.Resources>
	<phone:PhoneApplicationPage.ApplicationBar>
		<shell:ApplicationBar IsMenuEnabled="False">
			<shell:ApplicationBarIconButton x:Name="ReadButton" IconUri="/icons/appbar.download.rest.png" Text="Read" Click="OnClickReadButton"/>
			<shell:ApplicationBarIconButton x:Name="MapButton" IconUri="/icons/map.png" Text="Map" Click="MapButton_Click" />
			<shell:ApplicationBarIconButton x:Name="CommentsButton" IconUri="/icons/comments.png" Text="Comments" Click="CommentsButton_Click"/>
			<shell:ApplicationBarIconButton x:Name="EmailButton" IconUri="/icons/appbar.feature.email.rest.png" Text="Email" Click="EmailButton_Click"/>
		</shell:ApplicationBar>
	</phone:PhoneApplicationPage.ApplicationBar>
	<phone:PhoneApplicationPage.FontFamily>
		<StaticResource ResourceKey="PhoneFontFamilyNormal"/>
	</phone:PhoneApplicationPage.FontFamily>
	<phone:PhoneApplicationPage.FontSize>
		<StaticResource ResourceKey="PhoneFontSizeNormal"/>
	</phone:PhoneApplicationPage.FontSize>
	<phone:PhoneApplicationPage.Foreground>
		<StaticResource ResourceKey="PhoneForegroundBrush"/>
	</phone:PhoneApplicationPage.Foreground>
	<Grid x:Name="LayoutRoot" Background="Transparent" d:DataContext="{Binding Results[2]}">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
		
		<!--TitlePanel contains the name of the application and page title-->
		<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
			<StackPanel Margin="12,0" Orientation="Horizontal">
				<Image Height="30" Source="/icons/poweredby_nytimes_30a.png" Stretch="Fill" Width="30" Margin="0,0,4,0"/>
				<TextBlock x:Name="ApplicationTitle" Text="New York Times Most Popular" Style="{StaticResource PhoneTextNormalStyle}" Margin="0"/>
			</StackPanel>
			<TextBlock x:Name="PageTitle" Text="{Binding Title}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle2Style}" TextWrapping="Wrap"/>
		</StackPanel>

		<!--ContentPanel - place additional content here-->
		<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
			<ScrollViewer>
				<StackPanel Orientation="Vertical" VerticalAlignment="Top">
					<Grid x:Name="AuthorSection">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						<Image HorizontalAlignment="Left" Width="75" Source="{Binding Thumbnail, Mode=OneWay}" Margin="0,0,4,0"/>
						<StackPanel d:LayoutOverrides="Width" Grid.Column="1">
							<TextBlock x:Name="Byline" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Byline}" d:LayoutOverrides="Height" Style="{StaticResource PhoneTextSubtleStyle}" Margin="0">
								<TextBlock.Foreground>
									<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
								</TextBlock.Foreground>
							</TextBlock>
							<TextBlock x:Name="Pubdate" Margin="0" Style="{StaticResource PhoneTextSubtleStyle}" TextWrapping="Wrap" Text="{Binding PublishedDate, ConverterParameter=d, Converter={StaticResource DateTimeConverter}}" d:LayoutOverrides="Height">
								<TextBlock.Foreground>
									<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
								</TextBlock.Foreground>
							</TextBlock>
							<TextBlock x:Name="Source" Margin="0" Style="{StaticResource PhoneTextSubtleStyle}" TextWrapping="Wrap" Text="{Binding Source}">
								<TextBlock.Foreground>
									<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
								</TextBlock.Foreground>
							</TextBlock>
						</StackPanel>
						<StackPanel Grid.Column="2">
							<TextBlock x:Name="Section" Margin="0" Style="{StaticResource PhoneTextSubtleStyle}" TextWrapping="Wrap" Text="{Binding Section}" HorizontalAlignment="Right" FontWeight="Bold">
								<TextBlock.Foreground>
									<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
								</TextBlock.Foreground>
							</TextBlock>
							<TextBlock x:Name="Column" Margin="0" Style="{StaticResource PhoneTextSubtleStyle}" TextWrapping="Wrap" Text="{Binding Column}" HorizontalAlignment="Right">
								<TextBlock.Foreground>
									<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
								</TextBlock.Foreground>
							</TextBlock>
						</StackPanel>
					</Grid>
					<TextBlock x:Name="Abstract" Margin="0" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Text="{Binding Abstract}"/>
					<StackPanel x:Name="Facets">
						<TextBlock HorizontalAlignment="Left" Style="{StaticResource PhoneTextSubtleStyle}" TextWrapping="Wrap" Text="Subjects" VerticalAlignment="Top" Visibility="{Binding DescriptionFacets, Converter={StaticResource VisibleIfNotEmptyConverter}}">
							<TextBlock.Foreground>
								<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
							</TextBlock.Foreground>
						</TextBlock>
						<ItemsControl x:Name="DesFacet" HorizontalAlignment="Left" VerticalAlignment="Top" ItemTemplate="{StaticResource StringTemplate2}" ItemsSource="{Binding DescriptionFacets}" Margin="20,0,0,0" d:LayoutOverrides="HorizontalAlignment"/>
						<TextBlock HorizontalAlignment="Left" Style="{StaticResource PhoneTextSubtleStyle}" TextWrapping="Wrap" Text="People" VerticalAlignment="Top" Visibility="{Binding PerFacets, Converter={StaticResource VisibleIfNotEmptyConverter}}">
							<TextBlock.Foreground>
								<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
							</TextBlock.Foreground>
						</TextBlock>
						<ItemsControl x:Name="PerFacet" HorizontalAlignment="Left" ItemTemplate="{StaticResource StringTemplate}" ItemsSource="{Binding PerFacets}" Margin="20,0,0,0"/>
                        <TextBlock HorizontalAlignment="Left" Style="{StaticResource PhoneTextSubtleStyle}" TextWrapping="Wrap" Text="Companies &amp; Organizations" VerticalAlignment="Top" Visibility="{Binding OrgFacets, Converter={StaticResource VisibleIfNotEmptyConverter}}">
                            <TextBlock.Foreground>
								<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
							</TextBlock.Foreground>                            
                        </TextBlock>
						<ItemsControl x:Name="OrgFacet" HorizontalAlignment="Left" ItemTemplate="{StaticResource StringTemplate1}" ItemsSource="{Binding OrgFacets}" Margin="20,0,0,0"/>
						<TextBlock HorizontalAlignment="Left" Style="{StaticResource PhoneTextSubtleStyle}" TextWrapping="Wrap" Text="Geographic Locations" VerticalAlignment="Top" Visibility="{Binding GeoFacets, Converter={StaticResource VisibleIfNotEmptyConverter}}">
							<TextBlock.Foreground>
								<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
							</TextBlock.Foreground>
						</TextBlock>
						<ItemsControl x:Name="GeoFacet" HorizontalAlignment="Left" ItemTemplate="{StaticResource StringTemplate3}" ItemsSource="{Binding GeoFacets}" Margin="20,0,0,0"/>
					</StackPanel>
				</StackPanel>
			</ScrollViewer>
		</Grid>
        <Microsoft_Advertising_Mobile_UI:AdControl x:Name="AdControl" Grid.Row="2" AdUnitId="22465" AdModel="Contextual" 
            ApplicationId="a0177805-d056-40f9-ae53-6946fd5230bf"/>
	</Grid>
</phone:PhoneApplicationPage>